package com.qidian.tcba.admin.service.impl;


import com.qidian.tcba.admin.model.dto.assignTask.AssignTaskItemDTO;
import com.qidian.tcba.admin.model.dto.attachment.AttachmentBaseInfoDTO;
import com.qidian.tcba.admin.model.entity.Attachment;
import com.qidian.tcba.admin.service.ParkLotRecordAssignTaskItemService;
import com.qidian.tcba.dao.AttachmentMapper;
import com.qidian.tcba.dao.ParkLotRecordAssignTaskItemMapper;
import com.qidian.tcba.utils.BeanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 备案整改项表 服务实现类
 * </p>
 *
 * @author 冯永龙
 * @since 2021-07-06
 */
@Service
public class ParkLotRecordAssignTaskItemServiceImpl  implements ParkLotRecordAssignTaskItemService {

    @Autowired
    private ParkLotRecordAssignTaskItemMapper parkLotRecordAssignTaskItemMapper;

    @Autowired
    private AttachmentMapper attachmentMapper;

    @Override
    public List<AssignTaskItemDTO> getAssignTaskItems(int assignTaskId) {
        List<AssignTaskItemDTO> assignTaskItems = parkLotRecordAssignTaskItemMapper.getAssignTaskItems(assignTaskId);
        for (AssignTaskItemDTO assignTaskItem : assignTaskItems) {
            List<Attachment> attachments = attachmentMapper.getAttachments("ParkLotRecordAssignTaskItem", assignTaskItem.getId());
            assignTaskItem.setAttachments(BeanMapper.mapList(attachments,AttachmentBaseInfoDTO.class));
        }
        return assignTaskItems;
    }
}
